//
//  MOWorkTaskListViewCell.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/8/12.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#define CELLWIDTH  SCREEN_WIDTH - 30

#import "MOWorkTaskListViewCell.h"

@interface MOWorkTaskListViewCell ()

@property(nonatomic,strong)UIButton *nameButton;

@property(nonatomic,strong)UIView *lineView;

@property(nonatomic,strong)UILabel *dateLabel;

@property(nonatomic,strong)UILabel *taskStatusLabel;

@property(nonatomic,strong)UILabel *taskTypeLabel;

@property(nonatomic,strong)UILabel *auditPeopleLabel;

@property(nonatomic,strong)UILabel *auditIdeaLabel;


@end

@implementation MOWorkTaskListViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    //NSString *ID = [NSString stringWithFormat:@"Cell%ld%ld",(long)[indexPath section],(long)[indexPath row]];
    NSString *ID = @"MOWorkTaskListViewCell";
    MOWorkTaskListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil){
        cell = [[MOWorkTaskListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell creatView];
    }
    return cell;
}


-(void)creatView
{
    self.backgroundColor = KWhiteColor;
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 15.0;
    
    [self addSubview:self.nameButton];
    
    [self addSubview:self.lineView];
    
    [self addSubview:self.dateLabel];
    
    [self addSubview:self.taskStatusLabel];
    
    [self addSubview:self.taskTypeLabel];
    
    [self addSubview:self.auditPeopleLabel];
    
    [self addSubview:self.auditIdeaLabel];
}

-(void)setModel:(MOWorkTaskListModel *)model
{
    [self.nameButton setTitle:[NSString stringWithFormat:@" %@",model.nameStr] forState:UIControlStateNormal];
    
    self.dateLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"编辑时间\t%@",model.datestr] subString:model.datestr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
    
    self.taskStatusLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"任务状态\t%@",model.taskStatusStr] subString:model.taskStatusStr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
    
    self.taskTypeLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"任务类型\t%@",model.taskTypeStr] subString:model.taskTypeStr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
    
    self.auditPeopleLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"审核人    \t%@",model.auditPeopleStr] subString:model.auditPeopleStr subColor:KBlackColor_222222 subFont:[UIFont boldSystemFontOfSize:14]];
    
    self.auditIdeaLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"审核意见\t%@",model.auditIdeastr] subString:model.auditIdeastr subColor:KGreenColor_B7DAFF subFont:[UIFont boldSystemFontOfSize:14]];
}

#pragma mark --
-(UIButton *)nameButton
{
    if (!_nameButton) {
        _nameButton = [[UIButton alloc]initWithFrame:CGRectMake(17, 0, CELLWIDTH - 34, 50)];
        [_nameButton setTitleColor:KBlackColor_222222 forState:UIControlStateNormal];
        _nameButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        [_nameButton setImage:IMAGE(@"workTask") forState:UIControlStateNormal];
        [_nameButton setContentHorizontalAlignment:(UIControlContentHorizontalAlignmentLeft)];
    }
    return _nameButton;
}

-(UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, _nameButton.bottom, CELLWIDTH, 1)];
        _lineView.backgroundColor = KGrayColor_ededed;
    }
    return _lineView;
}

-(UILabel *)dateLabel
{
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _lineView.bottom + 18, CELLWIDTH - 34, 15)];
        _dateLabel.textColor = KGrayColor_919395;
        _dateLabel.font = FONT_SIZE(14);
    }
    return _dateLabel;
}

-(UILabel *)taskStatusLabel
{
    if (!_taskStatusLabel) {
        _taskStatusLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _dateLabel.bottom + 18, CELLWIDTH - 34, 15)];
        _taskStatusLabel.textColor = KGrayColor_919395;
        _taskStatusLabel.font = FONT_SIZE(14);
    }
    return _taskStatusLabel;
}

-(UILabel *)taskTypeLabel
{
    if (!_taskTypeLabel) {
        _taskTypeLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _taskStatusLabel.bottom + 18, CELLWIDTH - 34, 15)];
        _taskTypeLabel.textColor = KGrayColor_919395;
        _taskTypeLabel.font = FONT_SIZE(14);
    }
    return _taskTypeLabel;
}

-(UILabel *)auditPeopleLabel
{
    if (!_auditPeopleLabel) {
        _auditPeopleLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _taskTypeLabel.bottom + 18, CELLWIDTH - 34, 15)];
        _auditPeopleLabel.textColor = KGrayColor_919395;
        _auditPeopleLabel.font = FONT_SIZE(14);
    }
    return _auditPeopleLabel;
}

-(UILabel *)auditIdeaLabel
{
    if (!_auditIdeaLabel) {
        _auditIdeaLabel = [[UILabel alloc]initWithFrame:CGRectMake(17, _auditPeopleLabel.bottom + 18, CELLWIDTH - 34, 15)];
        _auditIdeaLabel.textColor = KGrayColor_919395;
        _auditIdeaLabel.font = FONT_SIZE(14);
    }
    return _auditIdeaLabel;
}



@end
